package com.zbkj.dal.base.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum FundTradeTypeEnums {

    /**
     * 退款返还
     */
    REFUND_RETURN("refund_return", "退款返还", "用户订单退款成功,返还余额{}元", "/crmebimage/public/product/2023/08/07/b2d7e50b4c5b49fa95a332833bee283fjqkkht9he3.png"),
    /**
     * 分润
     * 三方回调成功，创建分润单、创建流水-IN_TRANSIT
     */
    SHARE_PROFIT("share_profit", "分润", "订单：{}", "/crmebimage/public/product/2023/08/07/fb6857a8de8c420f9492b75c540c94bab6uaiae7q2.png"),
    /**
     * 提现
     * 创建提现单-NEW
     * 三方回调支付成功-FINISH
     * 失败/取消-CANCEL
     */
    WITHDRAW("withdraw", "提现", "", "/sxwxapp/static/images/meta/default/balance-withdraw.png"),
    WITHDRAW_RETURN("withdraw_return", "提现退回", "用户提现失败，退回{}元", "/sxwxapp/static/images/meta/default/balance-withdraw.png"),

    RECRUIT_REWARD("recruit_reward", "拉新奖励", "新朋友：{}", "/crmebimage/public/product/2023/08/07/098bd96bcca54dedb4307bc11f133470kfgjze2ajx.png"),

    /**
     * 订单
     */
    ORDER("order", "订单", "用户订单付款成功,扣余额{}元", "/crmebimage/public/product/2023/08/07/48c48a2d81cb4ae0917bc6c2378be4e6qars4sg3tr.png"),
    /**
     * 订单取消
     */
    ORDER_CANCEL("order_cancel", "订单取消", "用户订单取消成功,返还余额{}元", "/crmebimage/public/product/2023/08/07/48c48a2d81cb4ae0917bc6c2378be4e6qars4sg3tr.png"),

    /**
     * 系统后台
     */
    SYSTEM("system", "系统后台", "后台雅识操作,{}雅识{}元", "/sxwxapp/static/images/meta/default/balance-system-opreate.png"),
    /**
     * 佣金转余额
     */
    BROKERAGE("brokerage", "佣金转余额", "", "/crmebimage/public/product/2023/08/07/d7d080cd8c92469aad20265442c30ffajphojsf5gc.png"),
    /**
     * 会费充值
     */
    DUES("dues", "会费充值", "充值成功，余额增加{}元", "/crmebimage/public/product/2023/08/07/0ea4bb7c59a248f0943218b9ba2f334e64hq53p22r.png"),
    QUOTA_RECHARGE("quota_recharge", "额度充值", "额度充值成功，余额减少{}元", "/sxwxapp/static/images/meta/default/quota-recharge.png"),
    /**
     * 共享
     */
    SHARE("share", "共享", "", "/crmebimage/public/product/2023/08/07/dea241e7156c4d9c985c2cb08f51b5bf52gysavqk9.png"),

    ;

    private final String code;
    private final String desc;
    private final String remarkTemplate;
    private final String defaultImg;

    public static String getDescByCode(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        return Arrays.stream(FundTradeTypeEnums.values()).filter(type -> StringUtils.equals(type.getCode(), code)).map(FundTradeTypeEnums::getDesc).findFirst().orElse(null);
    }

    public static String getDefaultImage(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        return Arrays.stream(FundTradeTypeEnums.values()).filter(type -> StringUtils.equals(type.getCode(), code)).map(FundTradeTypeEnums::getDefaultImg).findFirst().orElse(null);
    }
}
